﻿

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title><script type="text/javascript" src="/js/jquery.1.5.js"></script><script type="text/javascript" src="/js/jquery.nhis.js"></script><script type="text/javascript" src="/js/jquery.rchis.js"></script><script type="text/javascript" src="/js/jquery-ui-custom.min.js"></script><script type="text/javascript" src="/js/css.js"></script><script type="text/javascript" src="/js/DatePicker/WdatePicker.js"></script><script type="text/javascript" src="/js/Common.js"></script><script type="text/javascript" src="/js/Jquery.commonGrid.js"></script>
        <script src="../../js/Uppop/tipswindown2.js"  type="text/javascript"></script>

        <link href="../../App_Themes/Theme2/Include.css" rel="stylesheet" type="text/css" />
          <script type="text/javascript">
              var isView = 'True'; //是否有浏览权限
              var isAdd = 'True' == 'True' ? '' : 'none'; //是否具有添加权限
              var isEdit = 'True' == 'True' ? '' : 'none'; //是否具有编辑权限
              var isDelete = 'True' == 'True' ? '' : 'none'; // 是否具有删除权限

              var AppPath = '';
              var handler = AppPath + '/do/Sys/SysModule.do';
              var PageSize = 20;
              var pager = null;
              $(function () {
                  if (isAdd == "none")  //判断权限添加按钮是否显示
                      $("#btnAdd").hide();

                  pager = $('#divPager').pager(AppPath, handler, function () {
                      return { ActionName: 'GetModules', MODULE_NAME: $('#txt_MODULE_NAME').val(), DATA_START: $('#txt_CREATE_START').val(), DATA_END: $('#txt_CREATE_END').val() };
                  }, function (data) {
                      var tbody = $('#tb tbody');
                      tbody.empty();
                      if (data && data.Entity && data.Entity.length) {
                          data = data.Entity
                          var tr, td;
                          for (var i = 0; i < data.length; i++) {
                              var item = data[i];
                              tr = $("<tr key=" + item.MODULE_KEY + "></tr>").appendTo(tbody);
                              $('<td></td>').appendTo(tr).html('<input  style="display:' + isEdit + '"  class="common_btn_edit mr12"  type="button" onclick="addModule(' + "'" + item.MODULE_KEY + "'" + ')" ><input style="display:' + isDelete + '" type="button" class="common_btn_del mr12"  onclick="deleteModule(' + "'" + item.MODULE_KEY + "'" + ')">');
                              $('<td></td>').appendTo(tr).text(item.MODULE_CODE);
                              $('<td></td>').appendTo(tr).text(item.MODULE_NAME);
                              $('<td></td>').appendTo(tr).text(item.MODULE_NAME_EN);
                              $('<td></td>').appendTo(tr).text(item.URL);
                              $('<td></td>').appendTo(tr).text(item.URL_PIC_SMALL);
                              $('<td></td>').appendTo(tr).text(item.URL_PIC_LARGE);
                              $('<td></td>').appendTo(tr).text(item.DATE_CREATE);
                          }
                      } else {
                          tbody.html('<tr><td colspan="9" style="text-align: center">没有数据!</td></tr>');

                      }
                      var tbHeight = $(window).height() - $(".common_search").height() - $("#divPager").height() - 30;
                      $("#tb").H8_Grid($("#divPager"), tbHeight);
                  }, PageSize, true);

                  /*
                  $("#txt_MODULE_NAME").Suggest(handler, { ActionName: "SuggestModule" }, function (data, selectedIndex, selectedItem) {
                  $("#txt_MODULE_NAME").val(data.Items[selectedIndex]);
                  //$("#btnSearch").click();
                  }, true);
                  */

                  $("#txt_MODULE_NAME").Suggest({ url: AppPath + "/do/Sys/SysModule.do", data: { ActionName: "SuggestModule" }, onSelect: function (data, selectedIndex, selectedItem) {
                      var dr = data.Data.Tables[0].Rows[selectedIndex];
                      $("#txt_MODULE_NAME").val(dr.MODULE_NAME);
                  }, mutiPage: true, minChars: 0, cache: true
                  });

                  $('#btn_search').click(function () {
                      pager.option.pageIndex = 1;
                      pager.getPegerData();
                      return false;
                  });
              });

              //弹出层
              function addModule(id) {
                  //window.parent.pop("添加模块", '/Login.aspx' + id, 800, 500, updateList)
                  window.parent.pop("添加模块", '/Sys/Module/Add.aspx?moduleKey=' + id, 850, 500, updateList)
              };

              function deleteModule(moduleKey) {
                  $.post(handler, { ActionName: "DeleteModule", moduleKey: moduleKey },
                   function (rslt) {
                       if (rslt.MessageCode == "Ok") {
                           $("tr[key='" + moduleKey + "']").remove();
                           alert("删除成功."); return;
                       }
                   }
                , "json");
              }




              //回调函数，弹出层保存成功之后执行，更新列表中数据，或往列表中添加新录的数据
              function updateList(obj, id) {
                  if ($.FxNull(id, "").length > 0) {//修改
                      $("#tb tbody tr[key='" + id + "']").html($(obj).html());

                  } else {//添加
                      $('#tb tbody').prepend(obj);

                  }
              }
      </script>
</head>
<body>
      <div class="warrper_body">  
         <div class="index" style=" overflow:hidden">
            <div class="common_search">
                 <div class="l_h45">  
                    编码/名称：<input type="text" id="txt_MODULE_NAME" value="" />
                    创建日期：<input id="txt_CREATE_START" style="width: 100px" type="text" onfocus="WdatePicker()" />
                    至<input id="txt_CREATE_END" style="width: 100px" type="text" onfocus="WdatePicker()" />
                    <span class="mr30"><input name=""  type="button"  class="btn_fasong3"/></span>
                    <input id="btnAdd" type="button"   class="common_btn_add2"  onclick="addModule('')"/>
                    <input name="" type="button"  class="btn_style" value="查看积分日志"/>
                    <input name="" type="button"  class="btn_style" value="查看积分日志"/>
                    <div><span class="mr30">所属店铺：
                       <input type="submit" name="button" id="button" value="选择/修改" class="common_btn_gaoji115" /></span>
                       <span class="gaoji_text">ddddddddddddddddddddddddddddddddddddddddddddddddddddd</span>
                       <span class="mr30"><input name="input" type="button"  class="btn_haocai"/></span>
                       <input name="input" type="button"  class="common_btn_gaoji"/>
                     </div>
                 </div>
            </div>
            <div class="l_h7"></div>
           
            <div class="index_table">
                <table id="tb" class="common_table">
                    <thead>
                        <tr>
                            <th width="100px" orderaction="false">操作</th>
                            <th width="100px" ordertype="string">模块编码</th>
                            <th width="150px" ordertype="string">模块名称</th>
                            <th width="200px" ordertype="string">模块英文名称</th>
                            <th width="200px" ordertype="string">访问路径</th>
                            <th width="300px" ordertype="string">小图标</th>
                            <th width="300px" ordertype="string">大图标</th>
                            <th width="100px" ordertype="string">创建时间</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td colspan="8" style="text-align: center"><input name="" type="button"  class="btn_style" value="查看积分日志"/></td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="page" id="divPager"></div>      
        </div>
     </div> 
</body>
</html>
